clear
use "justnormasylum.dta"

gen countyfip = cty_fips

merge 1:1 countyfip using "mobility_measures_collapsed_countyfip.dta"

keep if hasnormalorasylum==1

tostring countyfip, gen(cty_fipstr)
gen statefip = substr(cty_fipstr, 1,1) if length(cty_fipstr)==4
replace statefip = substr(cty_fipstr, 1, 2) if length(cty_fipstr)==5
destring statefip, replace

#delimit ;
local vars has8_par06_white has8_par06_black has9_par06_white has9_par06_black;

#delimit cr
foreach x of local vars{
#delimit ;
tabout hasnormalschool if hasnormalorasylum==1 using "sumstats.xls",
append c(mean `x' sd `x') npos(row) f(2)  layout(row) sum show(none);

reghdfe `x' hasnormalschool if hasnormalorasylum==1, absorb(statefip) cluster(statefip);
outreg2 using "EdMobility_1940.xls", append excel dec(2);
tab hasnormalschool if e(sample)==1;
};

#delimit cr
